import requests
import time

host = 'http://127.0.0.1/'

if __name__ == '__main__':
    session = requests.Session()

    # 登录
    res = session.post(f'{host}user/login/',
                       data={
                           'username': 'admin', 'password': 'admin',
                        #    'account': '0000000002', 'password': '123456',
                       }
                       )

    # 模拟cookie过期
    # time.sleep(4)

    # list 
    # res = session.get(f'{host}chat/api/chat/?receiver_id=2')
    # print(res.json())

    # create
    res=session.post(f'{host}chatrecord/api/chatrecord/',data={
        'receiver_id':'3',
        'content':'你爱吃什么水果?'
    })
    print(res.json())

    # update
    # res=session.put(f'{host}chat/api/chat/1/',data={
    #        'is_read':True,
    #        'is_return':True,
    #     })
    # print(res.json())

    # 获取指定时间段内的高频短语
    # res = session.get(f'{host}chat/high_rate_words/?start_time=0&end_time=16754151570')
    # print(res.json())
  